(function(){
	function initTemplate() {
		$.templates({
			channelTemplate: "#channelTemplate",
			channelSubTemplate: "#channelSubTemplate",
			programTemplate: "#programTemplate",
			programSubTemplate: "#programSubTemplate",
			episodeTemplate: "#episodeTemplate",
			episodeSubTemplate: "#episodeSubTemplate",
			episodeDetailTemplate: "#episodeDetailTemplate",
			contentsTemplate: "#contentsTemplate",
			likeStaticsTemplate: {
									markup: "#likeStaticsTemplate",
									templates: {
										likeAgeTemplate: "#likeAgeTemplate",
										likeRankTemplate: "#likeRankTemplate"
									}
								}
		});
	}
	$.views.helpers({
		getImageUrl: function( desc ){
			var img = window.getImageSrc(desc);
			return img == 'null' ? 'img/none.png' : img;
		},
		per: function( cnt, total ) {
			return Math.round((cnt / total ) * 100) + '%';
		},
		flag: function( flag ) {
			return flag == 'Y' ? 'class="on"' : '';
		},
		num: function( n ) {
			var nStr = n.toString();
			nStr += '';
			x = nStr.split('.');
			x1 = x[0];
			x2 = x.length > 1 ? '.' + x[1] : '';
			var rgx = /(\d+)(\d{3})/;
			while (rgx.test(x1)) {
				x1 = x1.replace(rgx, '$1' + ',' + '$2');
			}
			return x1 + x2;
		},
		date: function( d ){
			return CJ.util.getDate(d, '/');
		}
	});

	$.views.converters({
		
	});
	$(document).ready(function(){
		initTemplate();
	});
})();